<?php
class ListWidget extends BaseWidget{
	/**
	 * 显示前获取需要显示的数据
	 */
	public function get_data(){
		if(isset($this->config['limit'])){
			$limit = $this->config['limit'];
		}else{
			$limit = 7;
		}
		$mod = new ArticleModel();
		$articles = $mod->find(array('site_id'=>SITE_ID), null, 0, $limit);
		foreach ($articles as $article_id=>&$article){
			$cate = Article_cateModel::get_cate_by_key($article['cate']);
			if($cate!==null){
				$article['cate_name'] = $cate['name'];
				$article['cate'] = $cate;
				init_article_url($article, $cate['path']);
			}
		}
		return array('articles' => $articles);
	}
	
	/**
	 * 配置时处理Post数据
	 * @param $data 封装Post数据的数组
	 */	
	public function get_post_data(&$data){
		//$data['name'] = trim($_POST['name']);
		
	}
}
?>